import React from "react"
class Component1 extends React.Component{
  constructor(props){
    console.log("打印了constructor")
    super(props)
    this.state = {
      count:0
    }
  }

  componentDidMount(){
    console.log("打印了 didMount")
  }

  componentDidUpdate(){
    console.log("打印了 didUpdate")
  }

  componentWillMount(){
    console.log("打印了 willMount")
  }

  componentWillUnmount(){
    console.log("打印了 WillUnmount")

  }

  handelClick = ()=>{
    this.setState((state)=>{
      return {
        count: state.count+1
      }
    })
  }

  render(){
    console.log("打印了render")
    return (
      <div>
        <h1 onClick={this.handelClick}>this is component1 - {this.state.count}</h1>
      </div>
    )
  }
}

export default Component1